package cn.xiangyuanpin.web;

import cn.xiangyuanpin.service.UserService;
import cn.xiangyuanpin.service.impl.UserServiceImpl;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.lang.reflect.Method;

public abstract  class BaseServlet  extends HttpServlet {


    @Override
    protected void service(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        String action=req.getParameter("action");
        try {
            Method method=this.getClass().getDeclaredMethod(action,HttpServletRequest.class,HttpServletResponse.class);
            method.invoke(this,req,resp);
        } catch (Exception e){
            e.printStackTrace();
        }
       /* if(action.equals("register")){
           System.out.println("register访问");
           register(req, resp);
       }else if(action.equals("login")){
           System.out.println("login访问");
           login(req, resp);
       }*/
    }
}
